// @ts-check
import eslint from '@eslint/js';
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
import globals from 'globals';
import tseslint from 'typescript-eslint';
import stylistic from '@stylistic/eslint-plugin'; // 引入 stylistic 插件

export default tseslint.config(
  { ignores: ['eslint.config.mjs'] },

  eslint.configs.recommended,
  ...tseslint.configs.recommendedTypeChecked,
  eslintPluginPrettierRecommended,

  // 统一关闭 Prettier 的 semicolon，让它帮我们删分号
  {
    languageOptions: {
      globals: { ...globals.node, ...globals.jest },
      sourceType: 'commonjs',
      parserOptions: {
        projectService: true,
        tsconfigRootDir: import.meta.dirname,
      },
    },
  },

  // **关键** 1. 禁止多余分号，2. 可自动修复
  {
    plugins: { '@stylistic': stylistic },
    rules: {
      '@stylistic/no-extra-semi': 'error', // 禁止多余分号
      '@typescript-eslint/no-explicit-any': 'off',
      '@typescript-eslint/no-floating-promises': 'warn',
      '@typescript-eslint/no-unsafe-argument': 'warn',
    },
  },
);
